#ifndef DB_MANAGER_H
#define DB_MANAGER_H

#include <string>
#include <vector>
#include <map>

// Mock database implementation without SQLite
class DBManager {
public:
    DBManager();
    ~DBManager();

    // Initialize database
    bool initialize(const std::string& db_path);
    
    // User related operations
    bool createUser(const std::string& username, const std::string& password,
                    const std::string& phone, const std::string& email);
    bool authenticateUser(const std::string& username, const std::string& password, int& user_id);
    bool getUserInfo(int user_id, std::map<std::string, std::string>& user_info);
    bool updateUserBalance(int user_id, double amount);
    double getUserBalance(int user_id);
    
    // Keyword weight related operations
    bool setKeywordWeight(int user_id, const std::string& keyword, double weight);
    double getKeywordWeight(int user_id, const std::string& keyword);
    std::map<std::string, double> getKeywordsByUser(int user_id);
    
    // Payment related operations
    bool createPayment(int user_id, double amount, const std::string& order_id);
    bool updatePaymentStatus(const std::string& order_id, const std::string& status);
    std::vector<std::map<std::string, std::string>> getUserPayments(int user_id);
    
    // Transaction operations
    bool beginTransaction();
    bool commitTransaction();
    bool rollbackTransaction();

private:
    bool executeQuery(const std::string& query);
    bool executeQueryWithResult(const std::string& query, std::vector<std::map<std::string, std::string>>& results);
    std::string sanitizeString(const std::string& str);
    std::string getCurrentTimestamp();
    
    // Mock data storage (static to persist across instances)
    static std::map<int, std::map<std::string, std::string>> users_;
    static std::map<std::pair<int, std::string>, double> keyword_weights_;
    static std::vector<std::map<std::string, std::string>> payments_;
};

#endif // DB_MANAGER_H